/*
 * @Author: WuFeng <763467339@qq.com>
 * @Date: 2022-06-30 17:12:07
 * @LastEditTime: 2022-06-30 19:08:49
 * @LastEditors: WuFeng <763467339@qq.com>
 * @Description: 列设置
 * @FilePath: \vue3-element-plus-web\src\store\modules\columnSettingsDrawer.js
 * @Copyright 版权声明
 */
const columnSettingsDrawer = {
  state: {
    visible: false, // 抽屉 显示/隐藏 标记
    // 抽屉 loading 状态
    loading: false,
    // 当前打开的drawer所属模块信息
    current: {
      module: '', // 模块标识
      moduleName: '', // 模块名称
      params: {} // 传递给抽屉的参数
    }
  },

  mutations: {
    SET_COLUMN_SETTINGS_VISIBLE: (state, value) => {
      state.visible = value
    },
    SET_COLUMN_SETTINGS_LOADING: (state, value) => {
      state.loading = value
    },
    SET_COLUMN_SETTINGS_CURRENT: (state, value) => {
      state.current = value
    }
  },

  actions: {
    // 打开抽屉
    ShowColumnSettingsDrawer({ state, commit }, { module = '', params = {}}) {
      return new Promise((resolve, reject) => {
        // 设置显示状态为true
        commit('SET_COLUMN_SETTINGS_VISIBLE', true)
        resolve()
      })
    },
    //
    /**
     * @description 关闭抽屉
     * @param {} param0
     * @param {*.direct} Boolean 如果为true则直接关闭，如果为false则先判断是否有未保存数据进行提示二次确认
     * @returns Promise
     */
    CloseColumnSettingsDrawer({ commit, state }, params = {}) {
      return new Promise((resolve, reject) => {
        // 设置显示状态为false
        commit('SET_COLUMN_SETTINGS_VISIBLE', false)
        resolve()
      })
    }
  }
}

export default columnSettingsDrawer
